/**
 * All rights Reserved, Designed By 林溪开源
 * Copyright:    Copyright(C) 2016-2020
 * Company       林溪开源 Ltd.
 */

package com.boots.atomikos.business.afcustomer.service.impl;

import javax.transaction.Transactional;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.boots.atomikos.business.afcustomer.dao.IAfCustomerDao;
import com.boots.atomikos.business.afcustomer.model.AfCustomer;
import com.boots.atomikos.business.afcustomer.service.IAfCustomerService;
import com.boots.atomikos.business.afuser.dao.IAfUserDao;
import com.boots.atomikos.business.afuser.model.AfUser;
import com.module.boots.exception.CommonRuntimeException;

/**
 * 客户表逻辑服务实现层
 * @author：林溪
 * @date： 2020年11月17日
 */
@Service
public class AfCustomerServiceImpl extends ServiceImpl<IAfCustomerDao, AfCustomer> implements IAfCustomerService {

    @Autowired
    private IAfCustomerDao afCustomerDao;

    @Autowired
    private IAfUserDao afUserDao;

    @Override
    @Transactional(rollbackOn = CommonRuntimeException.class)
    public void test() {
        final AfCustomer afCustomer = AfCustomer.builder().customerName("客户1").build();
        final AfUser afUser = AfUser.builder().userName("用户1").build();
        final int i = afCustomerDao.insert(afCustomer);
        if (i > 0) {
            throw new CommonRuntimeException("新增失败");
        }
        afUserDao.insert(afUser);
    }

}
